package cn.gjculture.shopping.api.dao;

import cn.gjculture.shopping.api.entity.PostageTemplate;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface PostageTemplateDao{

    @Insert("insert into postagetemplate(postageTemplateId,templateType,area,postageTemplateName,firstPort,firstPortPostage," +
            "increase,increasePostage) values(#{postageTemplateId},#{templateType},#{area},#{postageTemplateName}," +
            "#{firstPort},#{firstPortPostage},#{increase},#{increasePostage})")
    int insert(PostageTemplate postageTemplate) ;

    @Select("select * from postagetemplate")
    List<PostageTemplate> query();

    @Select("select * from postagetemplate where postageTemplateId=#{id}")
    PostageTemplate queryById(String id);

    @Delete("delete from postagetemplate where postageTemplateId=#{id}")
    int delete(String id);
    @Select("select t1.* from postagetemplate t1 RIGHT join goodsmappostagetemplate t2 " +
            "on t1.postageTemplateId=t2.postageTemplateId where t2.goodsId=#{goodsId}")
    List<PostageTemplate> queryByGoodsId(String goodsId);

    @Delete("delete from goodsmappostagetemplate where postageTemplateId=#{id}")
    int deleteMapGoods(String id);

    @Select("select count(0) from goodsmappostagetemplate where postageTemplateId=#{id}")
    int queryCountMapGoodsById(String id);
}
